<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增仓库设置')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-warehouse-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">仓库编码：</label>
                <div class="col-sm-8">
                    <input id="'warehouseCode" name="warehouseCode" class="form-control" type="text" maxlength="16" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">仓库名称：</label>
                <div class="col-sm-8">
                    <input name="warehouseName" class="form-control" type="text" maxlength="30" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">所在城市：</label>
                <div class="col-sm-8">
                    <input name="city" class="form-control" type="text" maxlength="6" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">地址：</label>
                <div class="col-sm-8">
                    <input name="address" class="form-control" type="text"  maxlength="100" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">负责人：</label>
                <div class="col-sm-8">
                    <input name="principal" class="form-control" type="text" maxlength="6" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">联系方式：</label>
                <div class="col-sm-8">
                    <input name="telephone" class="form-control" type="text" maxlength="16" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control" maxlength="200"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "wh/warehouse"
        $("#form-warehouse-add").validate({
            onkeyup: false,
            rules:{
                warehouseCode:{
                    minlength: 2,
                    maxlength: 16,
                    remote: {
                        url: prefix + "/checkWarehouseCodeUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "warehouseCode": function() {
                                return $.common.trim($("#warehouseCode").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "warehouseCode": {
                    remote: "仓库编码已存在"
                },
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-warehouse-add').serialize());
            }
        }
    </script>
</body>
</html>